<?php

namespace Modules\AuthAdmin\Models;
use Modules\AuthAdmin\Services\QueryService;
class AuthGroup extends BaseApiModel
{
	/**
     * @name   状态0和1修改为true或false
     * @param  int  $value
     * @return Boolean 
     */
    public function getStatusAttribute($value)
    {
        return $value==1?true:false;
    }
	/**
     * @name   更新时间为null时返回
     * @param  int  $value
     * @return Boolean 
     */
    public function getUpdatedAtAttribute($value)
    {
        return $value?$value:'';
    }
	/**
	 * @name  列表数据
	 * @param  data  array 搜索数据
	 * @return json 
	 */
    public function list_data($data){
		$model = $this->query();
		$model = (new QueryService())->query_condition($model,$data,'name');	
        $list = $model->select('id','name','status','created_at','updated_at')
				->orderBy('id','desc') 
				->paginate($data['pagesize'])
				->toArray(); 
		return $this->api_success(['data'=>[
			'list'=>$list['data'],
			'total'=>$list['total']
		]]);		
	}
	
}
